package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.annotation.RequiresPermissionsDesc;
import com.qf.pojo.DtsAccountTrace;
import com.qf.service.DtsAccountTraceService;
import com.qf.util.ResponseUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author lixu
 */
@RestController
@RequestMapping("/admin/brokerage")
@CrossOrigin
public class BrokerageController {

    @Autowired
    private DtsAccountTraceService dtsAccountTraceService;

    /**
     *####  佣金管理
     *
     * ##### 2.1.2.1. 佣金列表
     *
     * - 接口地址 :http://localhost:8083/admin/brokerage/list?page=1&limit=20&username=1&mobile=1&statusArray=0&sort=add_time&order=desc
     *
     * - 下行数据 :
     */
    @RequiresPermissions(value = "admin:brokerage:list")
    @RequiresPermissionsDesc(menu = {"用户管理","佣金管理"},button = "查询")
    @GetMapping("/list")
    public Object list(@RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "20") Integer limit,
                       Integer status,
                       String mobile,
                       String username,
                       String sort,
                       String order,
                       String traceSn){
        //佣金管理分页
        IPage<DtsAccountTrace> iPage = dtsAccountTraceService.findListByQuery(status,mobile,username,page,limit,sort,order,traceSn);
        Map data = new HashMap<>();
        data.put("total",iPage.getTotal());
        data.put("traceList",iPage.getRecords());
        return ResponseUtil.ok(data);
    }
}
